﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using ImmlPad.Properties;

namespace ImmlPad.Documents
{
    public class ImmlDocument : DocumentBase
    {
        /// <summary>
        /// Creates an ImmlDocument with the default markup
        /// </summary>
        public ImmlDocument() 
            :base(Settings.Default.DefaultMarkup)
        {
            
        }

        /// <summary>
        /// Creates an ImmlDocument with the specified markup at the specified path
        /// </summary>
        /// <param name="markup"></param>
        /// <param name="fullPath"></param>
        public ImmlDocument(string markup, string fullPath)
            : base(markup, fullPath, string.Empty)
        { }

        public ImmlDocument(string markup, string fullPath, string foldingStates)
            : base(markup, fullPath, foldingStates)
        { }

        internal static ImmlDocument FromFile(string fullPath)
        {
            if (File.Exists(fullPath))
            {
                string sourceText = File.ReadAllText(fullPath);

                ImmlDocument document = new ImmlDocument(sourceText, fullPath);
                document.NeedsSave = false;

                return document;
            }

            return null;
        }
    }
}
